<template>
  <span>
    <span v-for="(btn, index) in btns" :key="index" style="margin:0 3px">
      <a-button
        @click="btnClick(btn.key)"
        :loading="loading(btn.key)"
        :disabled="btndisabled"
        v-bind="btn"
        v-if="btn.preventReClick !== undefined"
        v-preventReClick:[btn.key]="btn.preventReClick"
      >
        <!-- <a-icon v-if="btn.icon" :type="btn.icon" /> -->
        {{ btn.name }}
      </a-button>
      <a-button @click="btnClick(btn.key)" v-bind="btn" v-else>
        <!-- <a-icon v-if="btn.icon" :type="btn.icon" /> -->
        {{ btn.name }}
      </a-button>
    </span>
  </span>
</template>

<script>
import formMixin from '@/mixins/form-mixin'
export default {
  mixins: [formMixin],
  props: {
    // 按钮配置数组，每个按钮一个对象，参数如下：
    // {
    //     name: '', //必填
    //     key: '', //必填
    //     perm: '',
    //     preventReClick: true/false
    //     ...其他的a-button的属性
    // }
    // 组件上面可监听click，根据各个按钮的key来区分按钮
    btns: {
      type: Array,
      default: () => []
    }
  },
  computed: {
    btnType (type) {
      return function (type) {
        return !type ? 'default' : type
      }
    }
  },
  methods: {
    btnClick (key) {
      this.$emit('click', key)
    }
  }
}
</script>

<style></style>
